<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2022/12/29
  Time: 11:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%String path = request.getContextPath()+"/";%>
<!doctype html>
<html>
<head>
    <base href="<%=path%>">
    <title>新增编辑用户信息</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
    <script src="https://code.jquery.com/jquery-3.6.3.min.js"></script>
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->

    <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
</head>
<style>
input{
    width: 90%;
}
</style>
<body>
<div class="container-fluid">
   <div class="row" >
       <div  class="col-xs-12" >
           <form id="form1" style="margin:10px 0px;">
               <input type="hidden" name="id" value="${sessionScope.sdfsdf.id}"/>
               <input type="hidden" name="bz" value="${sessionScope.sdfsdf.bz}"/>
               <div class="form-group">
                   <div class="row">
                       <div class="col-xs-3 text-right" >
                           <label >原始密码：</label>
                       </div>
                       <div class="col-xs-9">
                           <input type="password" id="oldPwd" class="form-control" name="oldPwd"  placeholder="用户名">
                       </div>
                   </div>
               </div>
               <div class="form-group">
                   <div class="row">
                       <div class="col-xs-3 text-right" >
                           <label >新密码：</label>
                       </div>
                       <div class="col-xs-9">
                           <input type="password" id="loginPwd"  class="form-control" name="loginPwd"  placeholder="用户名">
                       </div>
                   </div>
               </div>
               <div class="form-group">
                   <div class="row">
                       <div class="col-xs-3 text-right" >
                           <label >确认密码：</label>
                       </div>
                       <div class="col-xs-9">
                           <input type="password" class="form-control" name="pwdAgin"  placeholder="用户名">
                       </div>
                   </div>
               </div>

               <button type="button" class="btn btn-primary " onclick="save()"><span class="glyphicon glyphicon-search"></span>搜索</button>

           </form>
       </div>
   </div>
</div>
</body>
<script src="static/js/layer/layer.js"></script>
<script src="static/js/plugins/validate/jquery.validate.min.js"></script>
<script src="static/js/plugins/validate/messages_zh.min.js"></script>
<script src="static/js/sofwin.js"></script>
<script>
    $(function(){
        $("#form1").validate({
            rules:{
                oldPwd:{
                    required: true,
                    remote:{
                        url: 'user/checkPwd',
                        type: 'get',
                        dataType: 'json',
                        data: {                     //要传递的数据
                            pwd: function() {
                                return $("#oldPwd").val();
                            }
                        }
                    }
                },
                loginPwd:"required",
                pwdAgin:{
                    required: true,
                    equalTo: $("#loginPwd")
                }

            },
            messages:{
                oldPwd:{
                    required: "旧密码不能为空",
                    remote:"密码错误"
                },
                loginPwd:"新密码不能为空",
                pwdAgin:{
                    required: "确认密码不能为空",
                    equalTo: "两次输入密码不一致"
                }
            }
        })
    })
    function save(){
        if($("#form1").valid()){
            $.operator.post('user/save',$("#form1").serialize(),function(){
                alert('修改成功')
            });
        }
    }
    <%--$(function(){--%>
    <%--    // 新增或编辑都需要加载部门信息--%>
    <%--    queryDepts();--%>
    <%--    loadUser();--%>
    <%--    function loadUser(){--%>
    <%--        var id = '${id}';--%>
    <%--        if(id!=''){--%>
    <%--            // 说明作用域中有id--%>
    <%--            $.operator.get('user/info/'+id,function(ret){--%>
    <%--                $("#userName").val(ret.result.userName);--%>
    <%--                //.....--%>
    <%--            });--%>
    <%--        }--%>
    <%--    }--%>
    <%--    function queryDepts(){--%>
    <%--        $.operator.get('dept/allDept',function(ret){--%>
    <%--            var depts = ret.result;--%>
    <%--            var $deptId = $("#deptId");--%>
    <%--            $deptId.html("");--%>
    <%--            for(var i=0;i<depts.length;i++){--%>
    <%--                $deptId.append('<option value="'+depts[i].id+'">'+depts[i].deptName+'</option>');--%>
    <%--            }--%>
    <%--        })--%>
    <%--    }--%>
    <%--})--%>

</script>
</html>
